package com.turing.common.entity;


public enum UserRoleEnum {

    UNDERWRITER(2, "underwriter"),
    BUSSINESS_MANAGER(3, "businessManager"),
    BUSINESS_EXECUTIVE(4, "businessExecutive"),
    RISK_MANAGER(5, "riskManager"),
    RISK_EXECUTIVE(6, "riskExecutive"),
    RISK_DIRECTOR(7, "riskDirector"),
    GENERAL_MANAGER(8, "generalManager"),
    CHAIRMNAN(9, "chairman");

    private Integer roleId;

    private String roleName;

    UserRoleEnum(Integer roleId, String roleName) {
        this.roleId = roleId;
        this.roleName = roleName;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }


    public static String getRoleName(Integer roleId) {
        UserRoleEnum[] enums = UserRoleEnum.values();
        for (int i = 0; i < enums.length; i++) {
            UserRoleEnum userRoleEnum = enums[i];
            if (userRoleEnum.roleId.equals(roleId)) {
                return userRoleEnum.roleName;
            }
        }
        return null;
    }

    public static Integer getRoleId(String roleName) {
        UserRoleEnum[] enums = UserRoleEnum.values();
        for (int i = 0; i < enums.length; i++) {
            UserRoleEnum userRoleEnum = enums[i];
            if (userRoleEnum.roleName.equalsIgnoreCase(roleName)) {
                return userRoleEnum.roleId;
            }
        }
        return null;
    }
}
